﻿
#region Usings

#endregion

namespace LongNet.Web.Email.Pop3
{
    /// <summary>
    /// Class for containing the messages
    /// returned by the Pop3Client class.
    /// </summary>
    public class Message : LongNet.Web.Email.Message
    {
        #region Constructors
        /// <summary>
        /// Constructor
        /// </summary>
        public Message()
            : base()
        {
        }
        #endregion

        #region Properties

        /// <summary>
        /// The number associated with the message
        /// </summary>
        public long MessageNumber { get; set; }

        /// <summary>
        /// Size of the message in bytes
        /// </summary>
        public long MessageSize { get; set; }

        /// <summary>
        /// If true, we've retrieved this message from the server
        /// </summary>
        public bool Retrieved { get; set; }

        /// <summary>
        /// MIME version of the email
        /// </summary>
        public MIME.MIMEMessage MessageBody { get; set; }

        #endregion

        #region Public Overridden Properties

        public override string Body
        {
            get
            {
                string ReturnValue = MessageBody.HTMLBodyText;
                if (string.IsNullOrEmpty(ReturnValue))
                    ReturnValue = MessageBody.PlainBodyText;
                if (string.IsNullOrEmpty(ReturnValue))
                    ReturnValue = MessageBody.BodyText;

                ReturnValue = ReturnValue.Replace("\r\n", "<br />");
                return ReturnValue;
            }
        }

        public override string From
        {
            get
            {
                return MessageBody.From;
            }
        }

        public override string To
        {
            get
            {
                return MessageBody.To;
            }
        }

        public override string Subject
        {
            get
            {
                return MessageBody.Subject;
            }
        }
        #endregion
    }
}